#ifndef IGSLIB_ACCEPTOR_H
#define IGSLIB_ACCEPTOR_H

#include <set>
#include <vector>
#include "igslib_iacceptor.h"

namespace igslib 
{
	class CAcceptor:public IAcceptor
	{
        protected:
            float value;
            ErrorState es;
            IMultiSortPath* msp;
            ISpi* spi;
            IGPIO* gpio;
			IGPIO* gpio_inhibt;
            std::set<IAcceptorEvent*> events;
            std::pair<float,float> confirm;
            float jt; // jammed time
            bool ha; // high active
            bool ihs; // Inhibitive State
            bool eec; // Enable Error Check
        public:
            CAcceptor()
            {
                value = 0;
                msp = nullptr;
                spi = nullptr;
                gpio = nullptr;
				gpio = nullptr;
				gpio_inhibt = nullptr;
                confirm = std::make_pair(22,160);
                jt = 160;
                ha = false;
                ihs = false;
                eec = true;
                ClearError();
            }
            virtual float GetValue() { return value; }
            virtual void SetValue(const float& value) { this->value = value; }
            virtual void AddValue(const float& value) { this->value += value; }
            virtual ErrorState GetErrorState() { return es; }
            virtual void SetErrorCheck(const bool& value) { eec = value; }
            virtual bool GetErrorCheck() { return eec; }
            virtual void ClearError() { es = ErrorState::None; }
            virtual void SetEventHandler(IAcceptorEvent* value) { events.insert(value); }
            virtual void Update() { }
            virtual void SetConfirmRange(const float& min,const float& max) { confirm = std::make_pair(min,max); }
            virtual void SetJammedTime(const float& value) { jt = value; }
            virtual void SetHighActive(const bool& value) { ha = value; }
            virtual void SetInhibitiveState(const bool& value) { ihs = value; }
            virtual bool GetInhibitiveState() { return ihs; }
            virtual void SetMultiSortPath(IMultiSortPath* value) { msp = value; }
            virtual IMultiSortPath* GetMultiSortPath() { return msp; }
            virtual void SetSPI(ISpi* value) { spi = value; }
            virtual void SetGPIO(IGPIO* value,IGPIO* value1) { gpio = value; gpio_inhibt = value1;}
	};

    class CAcceptorManager:public IAcceptorManager
    {
        static IAcceptorManager* instance;
        public:
            static IAcceptorManager* GetInstance();
            virtual IAcceptor* NewMHAcceptor();
			virtual IAcceptor* New_ProjMCU(const std::string& name);
    };
};

#endif
